using System;
using System.Collections.Generic;
using System.Text;
using TaugeLibrary.Classes.Attributes;
using TaugeLibrary.Interfaces;
using TaugeLibrary.UserControls;
using TaugeLibrary.Classes.Abstracts;
using TaugeLibrary.Enums;

namespace TaugeStock.BusinessUnit.Master.Store
{

    [AttTable("Store")]
    [AttPrimaryKey("store_id")]
    [AttUniqueKey("store_code")]
    class Store : ABusinessUnit
    {
        private int m_id;
        private string m_code;
        private string m_description;


        public Store(ITaugeFramework p_framework):base(p_framework){}                        

        [AttField("StoreID", eDBDataType.IDENTITY, 0,"Id")]
        [AttBindControl(eControlType.PROPERTY, "Id")]                
        public int ID { set { m_id = value; } get { return m_id; } }

        [AttField("StoreCode", eDBDataType.VARCHAR, 10,"Kode Toko")]
        [AttBindControl(eControlType.TEXTBOX, "txtCode")]                
        [AttSearchable]
        [AttKeyField]
        public string TestCode { set { m_code = value; } get { return m_code; } }

        [AttField("StoreName", eDBDataType.VARCHAR, 250, "Keterangan")]
        [AttBindControl(eControlType.TEXTBOX, "txtDescription")]
        [AttSearchable]
        public string TestDescription { set { m_description = value; } get { return m_description; } }


    }


    [AttBuMgr(
            UnitName = "Toko",
        //ListSql = "SELECT UserId, Username, UserDesc AS Keterangan, EmailAddr AS Email, CASE WHEN UserType=1 THEN 'GROUP' ELSE 'USER' END AS Tipe, IsActive AS Aktif FROM UserAccount WHERE 1<>2 ",
            Unit = "TaugeStock.BusinessUnit.Master.Store.Store",
            UnitUI = "TaugeStock.BusinessUnit.Master.Store.StoreUI",
            ImageRes = "",
            DllFile = "TaugeStock.dll",
            ListIsDistinct = false,
            ListColumns = new string[] { "ST.StoreID AS Id", "ST.StoreCode AS Kode", "ST.StoreName AS Keterangan" },
            ListTables = new string[] { "Store ST " },
            ListKeys = new string[] { "Id" },
            ListOrders = new string[] { "ST.StoreId" }
       )
   ]
    public class StoreManager : ABusinessUnitManager
    {
        public StoreManager() : base(App.Framework) { }
    }


    public class StoreUI : GeneralUI
    {
        public StoreUI(ITaugeFramework p_framework, ABusinessUnit p_unit)
            : base(p_framework, p_unit)
        {            
        }
    }
}
